import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: printerBack_DebugProcess
    width: 1760
    height: 935

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 30 : Cpp_Language.CurrentLanguage === 3 ? 30 : 40

    Rectangle{
        anchors.fill: parent
        border.width: 1
        color: "transparent"
    }

    Rectangle{
        anchors.left: printerBack_DebugProcess.left
        anchors.leftMargin: 10
        anchors.top: printerBack_DebugProcess.top
        anchors.topMargin: 10
        border.width: 1
        radius: 5
        width: 400
        height: 400
        color: "transparent"

        Rectangle{
            width: 400
            height: 60
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 5
            color: "transparent"

            Text{
                anchors.centerIn: parent
                font.pixelSize: fontSize
                font.bold: true
                text: qsTr("打印机类型")
            }

        }

        A_ComboBox{
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 70
            comboBoxWidth: 390
            comboBoxHeight: 80
            contentText_Fontsize: fontSize
            currentIndex: Cpp_Config.CurrentPrinter - 1
            itemHeight: 80
            model: [qsTr("瑞工RG-EL58"),qsTr("炜煌P16-L"),qsTr("达普DP-EH240L")]

            onComboBoxActivated: {
                // console.log("当前打印机类型: "+currentText)
                Cpp_Config.CurrentPrinter = currentIndex+1
                Cpp_Printer.PrinterType = currentIndex+1
            }

        }

    }


    Rectangle{
        anchors.left: printerBack_DebugProcess.left
        anchors.leftMargin: 10
        anchors.top: printerBack_DebugProcess.top
        anchors.topMargin: 420
        border.width: 1
        radius: 5
        width: 400
        height: 200
        color: "transparent"


        Rectangle{
            width: 400
            height: 60
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 5
            color: "transparent"

            Text{
                anchors.centerIn: parent
                font.pixelSize: fontSize
                font.bold: true
                text: qsTr("自动打印功能")
            }

        }

        A_Button{
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 80
            buttonWidth: 300
            buttonHeight: 80
            contentText_Data: Cpp_PLC.M_511 ? qsTr("已  启  用") : qsTr("未  启  用")
            isSelected: Cpp_PLC.M_511

            onButtonPressedAndHold: {
                if(!Cpp_PLC.M_511)
                {
                    Cpp_PLC.write_into_PLC_Coils(511,true)
                }
                else
                {
                    Cpp_PLC.write_into_PLC_Coils(511,false)
                }
            }

        }



    }



    Rectangle{
        anchors.horizontalCenter: printerBack_DebugProcess.horizontalCenter
        anchors.top: printerBack_DebugProcess.top
        anchors.topMargin: 10
        border.width: 1
        radius: 5
        width: 900
        height: 915
        color: "transparent"

        Rectangle{
            width: 400
            height: 60
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 5
            color: "transparent"

            Text{
                anchors.centerIn: parent
                font.pixelSize: fontSize
                font.bold: true
                text: qsTr("打印机输出内容")
            }

        }


        Column{
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 80

            spacing: 10

            Item{
                width: 600
                height: 80
                visible: !Cpp_PLC.M_394

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("高   度")
                    }

                }

                Rectangle{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    width: 300
                    height: 60
                    border.width: 3
                    radius: 5
                    border.color: "white"
                    color: "black"

                    Text{
                        id: materialHeightShow
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        color: "white"
                        text: Cpp_PLC.M_394 ? "NULL" : Cpp_PLC.Printer_Material_Height
                    }

                }


            }
            Item{
                width: 600
                height: 80

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("长  度")
                    }

                }

                Rectangle{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    width: 300
                    height: 60
                    border.width: 3
                    radius: 5
                    border.color: "white"
                    color: "black"

                    Text{
                        id: materialLengthShow
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        color: "white"
                        text: Cpp_PLC.Printer_Material_Length
                    }

                }
            }
            Item{
                width: 600
                height: 80

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("左 角 度")
                    }

                }

                Rectangle{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    width: 300
                    height: 60
                    border.width: 3
                    radius: 5
                    border.color: "white"
                    color: "black"

                    Text{
                        id: leftAngleShow
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        color: "white"
                        text: Cpp_PLC.M_390 ? "90" : "45"
                    }

                }

            }
            Item{
                width: 600
                height: 80

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("右 角 度")
                    }

                }

                Rectangle{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    width: 300
                    height: 60
                    border.width: 3
                    radius: 5
                    border.color: "white"
                    color: "black"

                    Text{
                        id: rightAngleShow
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        color: "white"
                        text: Cpp_PLC.M_391 ? "90" : "45"
                    }

                }


            }
            Item{
                width: 600
                height: 80

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("型材名称")
                    }

                }

                A_Textinput{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    inputWidth: 300
                    inputHeight: 80
                    fontPixelSize: fontSize
                    isPassword: false
                    onEditingFinished: function(value){
                        Cpp_Printer.MaterialName = value;
                    }
                }

            }
            Item{
                width: 600
                height: 80

                Rectangle{
                    width: 200
                    height: 60
                    anchors.left: parent.left
                    anchors.leftMargin: 30
                    anchors.verticalCenter: parent.verticalCenter
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("客户名称")
                    }

                }

                A_Textinput{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 300
                    inputWidth: 300
                    inputHeight: 80
                    fontPixelSize: fontSize
                    isPassword: false
                    onEditingFinished: function(value){
                        Cpp_Printer.CustomerName = value;
                    }
                }
            }

        }



        A_Button{
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 10
            anchors.horizontalCenter: parent.horizontalCenter
            buttonHeight: 80
            buttonWidth: 300
            contentText_Data: qsTr("打  印")
            onButtonClicked: Cpp_Printer.printerActive(materialHeightShow.text,
                                                       materialLengthShow.text,
                                                       leftAngleShow.text,
                                                       rightAngleShow.text)
        }


    }



}
